package android.common;

import org.apache.http.entity.StringEntity;

import android.common.Models.CalendarioAcademico;
import android.common.Models.CalificacionPeriodo;
import android.common.Models.Colegio;
import android.common.Models.Coordinador;
import android.common.Models.Curso;
import android.common.Models.EscalaNotas;
import android.common.Models.Estudiante;
import android.common.Models.Grado;
import android.common.Models.Indicador;
import android.common.Models.IndicadorEstudiantePeriodo;
import android.common.Models.Materia;
import android.common.Models.MateriaCurso;
import android.common.Models.MateriaGrado;
import android.common.Models.Matricula;
import android.common.Models.MensajeEstudiante;
import android.common.Models.Orientador;
import android.common.Models.Persona;
import android.common.Models.Profesor;
import android.common.Models.Secretario;
import android.common.Models.User;

import com.fasterxml.jackson.jr.ob.JSON;
import com.loopj.android.http.PersistentCookieStore;
//import android.util.Log;
import com.loopj.android.http.AsyncHttpClient;

public class EndPoints {
	public static boolean dev = true;
	public static String localhost = "http://10.0.2.2:9000";
	public static String remote = "http://app.alephsystems.co";
	public static String URL = dev ? localhost : remote;

	private static PersistentCookieStore cookieStore;

	public static void setCookieStore(PersistentCookieStore cookieStore) {
		EndPoints.cookieStore = cookieStore;
	}

	public static class ColegioInfoEP {
		private static String dTag = "ColegioInfoEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void getMaterias(JsonListRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/colegioinfo/materias";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class AcudienteEP {
		private static String dTag = "AcudienteEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void getIndicadoresPeriodo(Long idEstudiante,
				Long idMateria,
				JsonListRequestHandler<IndicadorEstudiantePeriodo> handler) {
			handler.setClazz(IndicadorEstudiantePeriodo.class);
			String url = URL + "/api/acudiente/getIndicadoresPeriodo/"
					+ idEstudiante + "/" + idMateria + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCalificacionesPeriodo(Long idEstudiante,
				Long idMateria,
				JsonListRequestHandler<CalificacionPeriodo> handler) {
			handler.setClazz(CalificacionPeriodo.class);
			String url = URL + "/api/acudiente/getCalificacionesPeriodo/"
					+ idEstudiante + "/" + idMateria + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateriasGrado(Long idEstudiante,
				JsonListRequestHandler<MateriaGrado> handler) {
			handler.setClazz(MateriaGrado.class);
			String url = URL + "/api/acudiente/getMateriasGrado/"
					+ idEstudiante + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getEstudiantes(
				JsonListRequestHandler<Estudiante> handler) {
			handler.setClazz(Estudiante.class);
			String url = URL + "/api/acudiente/getEstudiantes";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class SuperadminEP {
		private static String dTag = "SuperadminEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void crearPlantillaDemo(String nombreColegio,
				String prefijoColegio, JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/crearPlantillaDemo/"
					+ nombreColegio + "/" + prefijoColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void setEscalaNotas(Long idColegio, EscalaNotas body,
				JsonObjectRequestHandler<EscalaNotas> handler) {
			handler.setClazz(EscalaNotas.class);
			String url = URL + "/api/superadmin/setEscalaNotas/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getEscalaNotas(Long idColegio,
				JsonObjectRequestHandler<EscalaNotas> handler) {
			handler.setClazz(EscalaNotas.class);
			String url = URL + "/api/superadmin/getEscalaNotas/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteMateriaGrado(Long idMateria, Long idGrado,
				Long idColegio, JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/deleteMateriaGrado/"
					+ idMateria + "/" + idGrado + "/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newMateriaGrado(MateriaGrado body,
				JsonObjectRequestHandler<MateriaGrado> handler) {
			handler.setClazz(MateriaGrado.class);
			String url = URL + "/api/superadmin/newMateriaGrado";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateriasGrado(Long idGrado, Long idColegio,
				JsonListRequestHandler<MateriaGrado> handler) {
			handler.setClazz(MateriaGrado.class);
			String url = URL + "/api/superadmin/getMateriasGrado/" + idGrado
					+ "/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteGradoColegio(Long idGrado, Long idColegio,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/deleteGradoColegio/" + idGrado
					+ "/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteMateriaColegio(Long idMateria, Long idColegio,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/deleteMateriaColegio/"
					+ idMateria + "/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newGradoColegio(Grado body,
				JsonObjectRequestHandler<Grado> handler) {
			handler.setClazz(Grado.class);
			String url = URL + "/api/superadmin/newGradoColegio";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newMateriaColegio(Materia body,
				JsonObjectRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/superadmin/newMateriaColegio";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newCoordinador(Long idColegio, Coordinador body,
				JsonObjectRequestHandler<Coordinador> handler) {
			handler.setClazz(Coordinador.class);
			String url = URL + "/api/superadmin/newCoordinador/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newSecretario(Long idColegio, Secretario body,
				JsonObjectRequestHandler<Secretario> handler) {
			handler.setClazz(Secretario.class);
			String url = URL + "/api/superadmin/newSecretario/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newOrientador(Long idColegio, Orientador body,
				JsonObjectRequestHandler<Orientador> handler) {
			handler.setClazz(Orientador.class);
			String url = URL + "/api/superadmin/newOrientador/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newProfesor(Long idColegio, Profesor body,
				JsonObjectRequestHandler<Profesor> handler) {
			handler.setClazz(Profesor.class);
			String url = URL + "/api/superadmin/newProfesor/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getProfesores(Long idColegio,
				JsonListRequestHandler<Profesor> handler) {
			handler.setClazz(Profesor.class);
			String url = URL + "/api/superadmin/getProfesores/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getOrientadores(Long idColegio,
				JsonListRequestHandler<Orientador> handler) {
			handler.setClazz(Orientador.class);
			String url = URL + "/api/superadmin/getOrientadores/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getSecretarios(Long idColegio,
				JsonListRequestHandler<Secretario> handler) {
			handler.setClazz(Secretario.class);
			String url = URL + "/api/superadmin/getSecretarios/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCoordinadores(Long idColegio,
				JsonListRequestHandler<Coordinador> handler) {
			handler.setClazz(Coordinador.class);
			String url = URL + "/api/superadmin/getCoordinadores/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateColegio(Long idColegio, Colegio body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/updateColegio";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newColegio(Colegio body,
				JsonObjectRequestHandler<Colegio> handler) {
			handler.setClazz(Colegio.class);
			String url = URL + "/api/superadmin/newColegio";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getColegio(Long idColegio,
				JsonObjectRequestHandler<Colegio> handler) {
			handler.setClazz(Colegio.class);
			String url = URL + "/api/superadmin/getColegio/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getColegios(JsonListRequestHandler<Colegio> handler) {
			handler.setClazz(Colegio.class);
			String url = URL + "/api/superadmin/getColegios";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateMateria(Long idMateria, Materia body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/updateMateria/" + idMateria
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateGrado(Long idGrado, Grado body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/superadmin/updateGrado/" + idGrado + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateria(Long idMateria,
				JsonObjectRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/superadmin/getMateria/" + idMateria + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getGrado(Long idGrado,
				JsonObjectRequestHandler<Grado> handler) {
			handler.setClazz(Grado.class);
			String url = URL + "/api/superadmin/getGrado/" + idGrado + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getGradosColegio(Long idColegio,
				JsonListRequestHandler<Grado> handler) {
			handler.setClazz(Grado.class);
			String url = URL + "/api/superadmin/getGradosColegio/" + idColegio
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateriasColegio(Long idColegio,
				JsonListRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/superadmin/getMateriasColegio/"
					+ idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void goNext(Long idColegio,
				JsonListRequestHandler<String> handler) {
			handler.setClazz(String.class);
			String url = URL + "/api/superadmin/goNext/" + idColegio + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class QueryTesterEP {
		private static String dTag = "QueryTesterEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void query(String query, String params,
				JsonListRequestHandler<Object> handler) {
			handler.setClazz(Object.class);
			String url = URL + "/api/query_tester/query";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class CoordinadorEP {
		private static String dTag = "CoordinadorEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void getEstudiantesCurso(Long idCurso,
				JsonListRequestHandler<Estudiante> handler) {
			handler.setClazz(Estudiante.class);
			String url = URL + "/api/coordinador/getEstudiantesCurso/"
					+ idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newSecretario(Secretario body,
				JsonObjectRequestHandler<Secretario> handler) {
			handler.setClazz(Secretario.class);
			String url = URL + "/api/coordinador/newSecretario";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newOrientador(Orientador body,
				JsonObjectRequestHandler<Orientador> handler) {
			handler.setClazz(Orientador.class);
			String url = URL + "/api/coordinador/newOrientador";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newProfesor(Profesor body,
				JsonObjectRequestHandler<Profesor> handler) {
			handler.setClazz(Profesor.class);
			String url = URL + "/api/coordinador/newProfesor";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateCalendarioAcademico(
				Long idCalendarioAcademico, CalendarioAcademico body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/updateCalendarioAcademico/"
					+ idCalendarioAcademico + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCalendarioAcademicoActual(
				JsonObjectRequestHandler<CalendarioAcademico> handler) {
			handler.setClazz(CalendarioAcademico.class);
			String url = URL + "/api/coordinador/getCalendarioAcademicoActual";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateEstudiante(Long idEstudiante, Estudiante body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/updateEstudiante/"
					+ idEstudiante + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updatePersona(Long idPersona, Persona body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/updatePersona/" + idPersona
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newMatricula(Matricula body,
				JsonObjectRequestHandler<Matricula> handler) {
			handler.setClazz(Matricula.class);
			String url = URL + "/api/coordinador/newMatricula";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateCurso(Long idCurso, Curso body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/updateCurso/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateMateriaCurso(MateriaCurso body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/updateMateriaCurso";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getSecretarios(
				JsonListRequestHandler<Secretario> handler) {
			handler.setClazz(Secretario.class);
			String url = URL + "/api/coordinador/getSecretarios";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getProfesores(
				JsonListRequestHandler<Profesor> handler) {
			handler.setClazz(Profesor.class);
			String url = URL + "/api/coordinador/getProfesores";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateriasCurso(Long idCurso,
				JsonListRequestHandler<MateriaCurso> handler) {
			handler.setClazz(MateriaCurso.class);
			String url = URL + "/api/coordinador/getMateriasCurso/" + idCurso
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMaterias(JsonListRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/coordinador/getMaterias";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCurso(Long idCurso,
				JsonObjectRequestHandler<Curso> handler) {
			handler.setClazz(Curso.class);
			String url = URL + "/api/coordinador/getCurso/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteCurso(Long idCurso,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/coordinador/deleteCurso/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newCurso(Curso body,
				JsonObjectRequestHandler<Curso> handler) {
			handler.setClazz(Curso.class);
			String url = URL + "/api/coordinador/newCurso";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCursosGrado(Long idGrado,
				JsonListRequestHandler<Curso> handler) {
			handler.setClazz(Curso.class);
			String url = URL + "/api/coordinador/getCursosGrado/" + idGrado
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getGrados(JsonListRequestHandler<Grado> handler) {
			handler.setClazz(Grado.class);
			String url = URL + "/api/coordinador/getGrados";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newEstudiante(Estudiante body,
				JsonObjectRequestHandler<Estudiante> handler) {
			handler.setClazz(Estudiante.class);
			String url = URL + "/api/coordinador/newEstudiante";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getEstudiantes(String query,
				JsonListRequestHandler<Estudiante> handler) {
			handler.setClazz(Estudiante.class);
			String url = URL + "/api/coordinador/getEstudiantes";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void goNext(JsonListRequestHandler<String> handler) {
			handler.setClazz(String.class);
			String url = URL + "/api/coordinador/goNext";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getBoletin(Long idEstudiante,
				JsonListRequestHandler<vos.IndicadorBoletin> handler) {
			handler.setClazz(vos.IndicadorBoletin.class);
			String url = URL + "/api/coordinador/getBoletin/" + idEstudiante
					+ "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class ProfesorEP {
		private static String dTag = "ProfesorEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void getMyInfo(JsonObjectRequestHandler<Profesor> handler) {
			handler.setClazz(Profesor.class);
			String url = URL + "/api/profesor/getMyInfo";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getLista(Long idMateria, Long idCurso,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/profesor/getLista/" + idMateria + "/"
					+ idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getGrados(JsonListRequestHandler<Grado> handler) {
			handler.setClazz(Grado.class);
			String url = URL + "/api/profesor/getGrados";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMaterias(JsonListRequestHandler<Materia> handler) {
			handler.setClazz(Materia.class);
			String url = URL + "/api/profesor/getMaterias";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void sendMessage(
				JsonObjectRequestHandler<MensajeEstudiante> handler) {
			handler.setClazz(MensajeEstudiante.class);
			String url = URL + "/api/profesor/sendMessage";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void setCalificacionPeriodo(CalificacionPeriodo body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/profesor/setCalificacionPeriodo";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteIndicadorEstudiante(Long idEstudiante,
				Long idMateria, Long idGrado, String categoria,
				Integer consecutivo, JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/profesor/deleteIndicadorEstudiante/"
					+ idEstudiante + "/" + idMateria + "/" + idGrado + "/"
					+ categoria + "/" + consecutivo + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newIndicadorEstudiante(
				IndicadorEstudiantePeriodo body,
				JsonObjectRequestHandler<IndicadorEstudiantePeriodo> handler) {
			handler.setClazz(IndicadorEstudiantePeriodo.class);
			String url = URL + "/api/profesor/newIndicadorEstudiante";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getIndicadoresEstudiantes(Long idCurso,
				Long idMateria,
				JsonListRequestHandler<IndicadorEstudiantePeriodo> handler) {
			handler.setClazz(IndicadorEstudiantePeriodo.class);
			String url = URL + "/api/profesor/getIndicadoresEstudiantes/"
					+ idCurso + "/" + idMateria + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void deleteIndicador(Long idMateria, Long idGrado,
				String categoria, Integer consecutivo,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/profesor/deleteIndicador/" + idMateria
					+ "/" + idGrado + "/" + categoria + "/" + consecutivo + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void updateIndicador(Long idMateria, Long idGrado,
				String categoria, Integer consecutivo, Indicador body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/profesor/updateIndicador/" + idMateria
					+ "/" + idGrado + "/" + categoria + "/" + consecutivo + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void newIndicador(Long idMateria, Long idGrado,
				Indicador body, JsonObjectRequestHandler<Indicador> handler) {
			handler.setClazz(Indicador.class);
			String url = URL + "/api/profesor/newIndicador/" + idMateria + "/"
					+ idGrado + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCurso(Long idCurso,
				JsonObjectRequestHandler<Curso> handler) {
			handler.setClazz(Curso.class);
			String url = URL + "/api/profesor/getCurso/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getIndicadores(Long idMateria, Long idGrado,
				JsonListRequestHandler<Indicador> handler) {
			handler.setClazz(Indicador.class);
			String url = URL + "/api/profesor/getIndicadores/" + idMateria
					+ "/" + idGrado + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMateriasGrado(
				JsonListRequestHandler<MateriaGrado> handler) {
			handler.setClazz(MateriaGrado.class);
			String url = URL + "/api/profesor/getMateriasGrado";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCalificacionesPeriodo(Long idMateria,
				Long idCurso,
				JsonListRequestHandler<CalificacionPeriodo> handler) {
			handler.setClazz(CalificacionPeriodo.class);
			String url = URL + "/api/profesor/getCalificacionesPeriodo/"
					+ idMateria + "/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getCalificacionesPeriodos(Long idMateria,
				Long idCurso,
				JsonListRequestHandler<CalificacionPeriodo> handler) {
			handler.setClazz(CalificacionPeriodo.class);
			String url = URL + "/api/profesor/getCalificacionesPeriodos/"
					+ idMateria + "/" + idCurso + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMisAsignaturas(
				JsonListRequestHandler<MateriaCurso> handler) {
			handler.setClazz(MateriaCurso.class);
			String url = URL + "/api/profesor/getMisAsignaturas";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

	public static class UserEP {
		private static String dTag = "UserEP";
		private static AsyncHttpClient client = new AsyncHttpClient();

		public static void getPersonasConDocumento(String documento,
				JsonListRequestHandler<Persona> handler) {
			handler.setClazz(Persona.class);
			String url = URL + "/api/personas/" + documento + "";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void uploadFile(JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/uploadFile";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void getMyInfo(JsonObjectRequestHandler<User> handler) {
			handler.setClazz(User.class);
			String url = URL + "/api/getMyInfo";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void logout(JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/logout";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.get(url, handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

		public static void login(vos.LoginCredentials body,
				JsonObjectRequestHandler<Void> handler) {
			handler.setClazz(Void.class);
			String url = URL + "/api/login";
			// Log.d(dTag, "Requesting to url: " + url);
			client.setCookieStore(EndPoints.cookieStore);
			try {
				client.post(null, url,
						new StringEntity(JSON.std.asString(body)),
						"application/json", handler);
			} catch (Exception e) {
				handler.onFailure(-1, null, (String) null, e);
			}
		}

	}

}
